package com.chinacache.maint.workorder.entity;

import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import com.chinacache.maint.commons.entity.BaseEntity;

@Entity
@Table(name = "WO_FIELD")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Field extends BaseEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer id;
	private String name;
	private String memo;

	private Set<FieldAttribute> fieldAttibutes = new LinkedHashSet<FieldAttribute>(
			0);
	private Set<FieldClassToField> fieldClassFields = new LinkedHashSet<FieldClassToField>(
			0);

	@OneToMany(mappedBy = "field")
	public Set<FieldClassToField> getFieldClassFields() {
		return fieldClassFields;
	}

	public void setFieldClassFields(Set<FieldClassToField> fieldClassFields) {
		this.fieldClassFields = fieldClassFields;
	}

	@Column(name = "NAME")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Id
	@Column(name = "FIELD_ID")
	@GeneratedValue(generator = "SEQ_RPT_USER_TO_CLASS")
	@GenericGenerator(name = "SEQ_RPT_USER_TO_CLASS", strategy = "seqhilo", parameters = { @Parameter(name = "sequence", value = "SEQ_RPT_USER_TO_CLASS") })
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "field")
	@OrderBy("groupId")
	public Set<FieldAttribute> getFieldAttibutes() {
		return fieldAttibutes;
	}

	public void setFieldAttibutes(Set<FieldAttribute> fieldAttibutes) {
		this.fieldAttibutes = fieldAttibutes;
	}

	@Column(name = "MEMO")
	public String getMemo() {
		return memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}
}
